package com.javasm.springmybatis.mail;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.util.concurrent.TimeUnit;

/**
 * @Author：xieyunfan
 * @Version：1.0
 * @Date：2021/12/30-0:03
 * @Since:jdk1.8
 * @Description:
 */
@Component
public class EmailService {

    @Async
    public void sendEmail() {
        //因为耗时操作，所以要耗时
        String name = Thread.currentThread().getName();
        System.out.println(name);

       //睡三秒
        try {
            System.out.println(name+"睡了");
            TimeUnit.SECONDS.sleep(3);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

//       String code="dsdf";
//       SimpleMailMessage simpleMailMessage = new SimpleMailMessage();
//       simpleMailMessage.setFrom("谢闯<xyunf1010@163.com>");
//       simpleMailMessage.setSubject("验证码");
//       simpleMailMessage.setText(code);
//       simpleMailMessage.setTo(email);
//              javaMailSender.send(simpleMailMessage);

    }
}
